package com.chaoyong.higo.fragment;

import com.chaoyong.higo.R;
import com.chaoyong.higo.adapter.ViewPageFragmentAdapter;
import com.chaoyong.higo.base.BaseViewpagerFragmentNormal;
import com.chaoyong.higo.interf.OnTabReselectListener;

import android.support.v4.app.Fragment;

/**
 * 装载5个fragment用，分别是获得商品--全部、待收货、待确认、已完成、待晒单
 * 
 * @author Administrator
 *
 */
public class FragGetgoodsPagers extends BaseViewpagerFragmentNormal implements OnTabReselectListener {

	@Override
	protected void onSetupTabAdapter(ViewPageFragmentAdapter adapter) {
		String[] title = getResources().getStringArray(R.array.get_goods);
		adapter.addTab(title[0], "getGoods0", FragGetGoods0.class);
		adapter.addTab(title[1], "getGoods1", FragGetGoods1.class);
		//adapter.addTab(title[2], "getGoods2", FragGetGoods2.class);
		adapter.addTab(title[3], "getGoods3", FragGetGoods3.class);
		//adapter.addTab(title[4], "getGoods4", FragGetGoods4.class);
	}

	@Override
	protected void setScreenPageLimit() {
		mViewPager.setOffscreenPageLimit(3);
	}

	@Override
	public void onTabReselect() {
		try {
			int currentIndex = mViewPager.getCurrentItem();
			Fragment currentFragment = getChildFragmentManager().getFragments().get(currentIndex);
			if (currentFragment != null && currentFragment instanceof OnTabReselectListener) {
				OnTabReselectListener listener = (OnTabReselectListener) currentFragment;
				listener.onTabReselect();
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
